package opration;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2024-10-14
 * Time: 18:52
 */
public class delBook implements IOprable{
    @Override
    public void work(BookList bookList) {
        System.out.println("删除图书");
        //让后面的图书覆盖前面的图书
        System.out.println("请输入你要删除的图书");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        //找到name 的下标 ,循环中 i 就是下标
        BookList bk = new BookList();
        int size = bk.getSize();
        for (int i =0 ;i<size;i++){

            if(bk.books[i].getName().equals(name)){
                //删除的图书下标 int ptr = i;
                Book tmp = bk.books[i+1];
                bk.books[i] = tmp;
                //bk.putBook(i,tmp);
                return;
            }
        }



    }
}
